using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class GlhistMap : EntityTypeConfiguration<Glhist>
    {
        public GlhistMap()
        {
            // Primary Key
            this.HasKey(t => t.GLHIST_ID);

            // Properties
            this.Property(t => t.PERIOD)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Glhist");
            this.Property(t => t.GLHIST_ID).HasColumnName("GLHIST_ID");
            this.Property(t => t.OLDDR).HasColumnName("OLDDR");
            this.Property(t => t.OLDCR).HasColumnName("OLDCR");
            this.Property(t => t.CURDR).HasColumnName("CURDR");
            this.Property(t => t.CURCR).HasColumnName("CURCR");
            this.Property(t => t.PERIOD).HasColumnName("PERIOD");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.OLDDRDOL).HasColumnName("OLDDRDOL");
            this.Property(t => t.OLDCRDOL).HasColumnName("OLDCRDOL");
            this.Property(t => t.CURDRDOL).HasColumnName("CURDRDOL");
            this.Property(t => t.CURCRDOL).HasColumnName("CURCRDOL");
            this.Property(t => t.OLDDRACCT).HasColumnName("OLDDRACCT");
            this.Property(t => t.OLDCRACCT).HasColumnName("OLDCRACCT");
            this.Property(t => t.CURDRACCT).HasColumnName("CURDRACCT");
            this.Property(t => t.CURCRACCT).HasColumnName("CURCRACCT");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.UPDATEPD).HasColumnName("UPDATEPD");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.Glhists)
                .HasForeignKey(d => d.ACCT);
            this.HasRequired(t => t.Period1)
                .WithMany(t => t.Glhists)
                .HasForeignKey(d => d.PERIOD);

        }
    }
}
